#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>

int main(void)
{
	int data_processed;
	int file_pipes[2];
	const char some_data[] = "123";
	char buffer[BUFSIZ + 1];
	pid_t fork_result;

	memset(buffer, 0, sizeof(buffer));
	if (pipe(file_pipes) == 0)
	{
		fork_result = fork();
		if (-1 == fork_result)
		{
			perror("Fork failure");
			exit(EXIT_FAILURE);
		}
		else if (0 == fork_result)
		{
			close(0);
			dup(file_pipes[0]);
			close(file_pipes[0]);
			close(file_pipes[1]);

			execlp("od", "od", "-c", (char*)0);
		}
		else
		{
            close(file_pipes[0]);
			data_processed = write(file_pipes[1], some_data, strlen(some_data));
			close(file_pipes[1]);
			printf("%d - wrote %d bytes\n", getpid(), data_processed);
		}
	}

	return 0;
}
